<div class="container-flunews_id">
    <?php
    $categories = $viewModel->get('category');
    $news = $viewModel->get('news');
    
    if(!is_object($news)){
        echo 'News is not exist!';
    }else{
        ?>
        
        <h1>News Update form</h1>
        <form class="form-horizontal" method="POST" enctype="multipart/form-data">
            <div class="control-group" style="display: none;">
                <label class="control-label" for="inputnews_id">News ID</label>
                <div class="controls">
                    <input type="text" id="inputnews_id" name="news_id" value="<?php echo $news->news_id; ?>" />
                </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="inputtitle">Title</label>
                <div class="controls">
                    <input type="text" id="inputtitle" name="title" value="<?php echo $news->title; ?>" placeholder="title" required="required">
                </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="inputCategoryID">Category</label>
                <div class="controls">
                    <select id="inputCategoryID" name="category_id">
                        <?php
                        foreach ($categories as $categories) {
                            if ($categories->category_id == $news->category_id) {
                                $choice = "selected = 'selected'";
                            } else {
                                $choice = "";
                            }
                            echo "<option value='" . $categories->category_id . "'" . $choice . ">" . $categories->category_name . "</option>";
                        }
                        ?>
                    </select>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="inputContent">Content</label>
                <div class="controls" id="forInputContent">
                    <textarea id="inputContent" class="editor_noimage" name="content" placeholder="Content" style="margin: 0px; height: 167px; width: 457px;"><?php echo $news->content; ?></textarea>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="inputBody">Body</label>
                <div class="controls">
                    <textarea id="inputBody" class="editor_noimage" name="body" placeholder="Body" style="margin: 0px; height: 167px; width: 457px;"><?php echo $news->body; ?></textarea>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="inputUsername">Status</label>
                <div class="controls">
                    <select name="status">
                        <option value="0" <?php echo ($news->status == 0) ? "selected = 'selected'" : "" ?>>Deactive</option>
                        <option value="1" <?php echo ($news->status == 1) ? "selected = 'selected'" : "" ?>>Active</option>
                    </select>
                </div>
            </div>
 
            <div class="control-group">
                <div class="controls">
                    <button type="submit" class="btn btn-success">Submit</button>
                    <button type="reset" class="btn">Reset</button>
                </div>
            </div>
        </form>
    <?php } ?>
</div>
